<?php 
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;
use \PsiFramework\Classes\Util\UI\LanguageManager;
use \PsiFramework\Classes\Util\HTTP\AuthenticationManager;
?>
<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="utf-8">
        <title>AlloMedia</title>
        
        <!-- meta -->
        <meta name="description" content="AlloMedia">
        <meta name="author" content="Rémi San">

        <!-- Scripts -->
        <?php
        foreach ($templateManager->getRemoteScripts() as $remote) {
        ?>
        <script
            type="text/javascript"
            src="<?php Printer::display($remote); ?>"></script>
        <?php
        }
        
        //TODO passer le js dans les actions
        $js = 'Applications/DefaultApp/Template/scripts/psiframework.js,' ;
        ?>
        <script
            type="text/javascript"
            src="Scripts/scripts.php?file=<?php
                Printer::display($js.$templateManager->getScriptFileList());
        ?>"></script>
        <?php
        if ($templateManager->hasScripts()) { ?>
        <script type="text/javascript">
            <?php echo $templateManager->getScriptList(); ?>
        </script>
        <?php
        }
        ?>
        
        
        <!-- Styles -->
        <?php
        foreach ($templateManager->getRemoteStyles() as $remote) {
        ?>
        <link
            rel="stylesheet"
            type="text/css"
            href="<?php Printer::display($remote); ?>"
            media="screen" />
        <?php
        }
        //TODO passer le css dans les actions
        $css = 'Applications/AlloMediaPortal/Template/styles/jquery.css,';
        ?>
        <link
            rel="stylesheet"
            type="text/css"
            href="Styles/styles.php?file=<?php Printer::display($css.$templateManager->getStyleFileList()); ?>"
            media="screen" />
        <?php
        if ($templateManager->hasStyles()) {
        ?>
        <style type="text/css" media="screen">
            <?php echo $templateManager->getStyleList(); ?>
        </style>
        <?php
        }
        ?>

        <link rel="shortcut icon" href="./Images/AlloMedia/allomedia.ico">

    </head>
    <body>
        <div id="wrapper">
            <header>
                <?php 
                $languageManager = LanguageManager::getInstance();
                $action = "Authenticate" ;
                $text = "LOGOUT" ;
                if (AuthenticationManager::getInstance()->getAuthenticatedUser()===null) {
                    $action = "Login" ;
                    $text = "LOGIN" ;
                }
                $text = $languageManager->getText($text);
                echo HTML::link($text, "action=".$action);
                ?>
            </header>
            <menu>
                <li>
                    <?php echo HTML::link('Paramètres utilisateur', "action=EditUser"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Applications", "action=CMS.List&type=ApplicationConfiguration"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Utilisateurs", "action=CMS.List&type=User"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Styles", "action=CMS.List&type=Style"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Pages", "action=CMS.List&type=Page"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Textes", "action=CMS.List&type=Text"); ?>
                </li>
            </menu>
            <menu>
                <li>
                    <?php echo HTML::link("Types de champs", "action=CMS.List&type=FieldType"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Champs", "action=CMS.List&type=FormField"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Themes", "action=CMS.List&type=Form"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Fiches", "action=CMS.List&type=InformationProfile"); ?>
                </li>
            </menu>
            <menu>
                <li>
                    <?php echo HTML::link("Thèmes à débloquer", "action=CMS.List&type=ResponseId"); ?>
                </li>
            </menu>
            <menu>
                <li>
                    <?php echo HTML::link("Sites", "action=CMS.List&type=AlloMediaSite"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Entrées", "action=CMS.List&type=AlloMediaEntry"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Catégories", "action=CMS.List&type=SiteCategory"); ?>
                </li>
            </menu>
            <menu>
                <li>
                    <?php echo HTML::link("Catégories de la boutique", "action=CMS.List&type=ItemCategory"); ?>
                </li>
                <li>
                    <?php echo HTML::link("Remises", "action=CMS.List&type=Discount"); ?>
                </li>
            </menu>
            <menu>
                <li>
                    <?php echo HTML::link("Logs", "action=List2&type=Trace&orderColumn=time&sens=DESC&page=1&nbResults=100"); ?>
                </li>
            </menu>
            <div>
                <?php $templateManager->displayTemplate('main');  ?>
            </div>
        </div>
        <?php $templateManager->displayTemplate('Debug', $response);  ?>
    </body>
</html>
